const axios = require('axios');

const apiUrl = 'https://api.baidu.com/json/tongji/v1/ReportService/getData';

const requestData = {
  header: {
    userName: 'Murara',
    accessToken:
      'eyJhbGciOiJIUzM4NCJ9.eyJzdWIiOiJhY2MiLCJhdWQiOiLnmb7luqbnu5_orqEiLCJ1aWQiOjUyNjM0MDMzLCJhcHBJZCI6IjEzYmQ1MDQ5YTY3NmQxMDczNzk1OTkzMjEwMmVjNTU3IiwiaXNzIjoi5ZWG5Lia5byA5Y-R6ICF5Lit5b-DIiwicGxhdGZvcm1JZCI6IjQ5NjAzNDU5NjU5NTg1NjE3OTQiLCJleHAiOjE3MDc0MDMwNDksImp0aSI6IjgyMjA3Mzk4MjE3MTk5MTI0NDkifQ.Ymsj_6J47pAp4diywHnx2WU0Mx4RKcTsjoGYnfKXjTN7_yMaPTDi8EB1H0H_hA42',
  },
  body: {
    site_id: 'your_site_id',
    start_date: '20190101',
    end_date: '20190105',
    metrics: 'pv_count,visitor_count,ip_count',
    method: 'overview/getTimeTrendRpt',
  },
};

axios
  .post(apiUrl, requestData, {
    headers: {
      'Content-Type': 'application/json',
    },
  })
  .then((response) => {
    // 处理响应数据
    console.log(response.data);
  })
  .catch((error) => {
    // 处理错误
    console.error(error);
  });
